package com.example.xujin.owncode.Adaapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.xujin.owncode.Bean.ClassInfoBean;
import com.example.xujin.owncode.R;

import java.util.List;

import butterknife.BindView;

/**
 * Created by xujin on 2019/7/15.
 */

public class Activity_2_Adp extends RecyclerView.Adapter {
    private List<ClassInfoBean.DataBean> list;
    private Context mContext;

    private int GROUP_ITEM = 0;
    private int NORMAL_ITEM = 1;

    public Activity_2_Adp(List<ClassInfoBean.DataBean> list, Context mContext) {
        this.list = list;
        this.mContext = mContext;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        if (viewType == GROUP_ITEM) {
            ViewHolder01 holder01 = new ViewHolder01(LayoutInflater.from(mContext).inflate(R.layout.bill_item_view_list, parent, false));
            return holder01;
        } else {
            ViewHolder02 holder02 = new ViewHolder02(LayoutInflater.from(mContext).inflate(R.layout.classinfo_day, parent, false));
            return holder02;
        }

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ViewHolder01) {
        }
    }

    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return GROUP_ITEM;
        }
        String data = list.get(position).getHowDate().substring(0, 7);
        String data_before = list.get(position).getHowDate().substring(0, 7);
        if (data.equals(data_before)) {
            return NORMAL_ITEM;
        } else {
            return GROUP_ITEM;
        }
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class ViewHolder01 extends RecyclerView.ViewHolder {
        @BindView(R.id.group_item_time)
        TextView group_item_time;
        @BindView(R.id.tv_month)
        TextView tv_month;
        @BindView(R.id.tv_day)
        TextView tv_day;
        @BindView(R.id.tv_date)
        TextView tv_date;
        @BindView(R.id.tv_isSign)
        TextView tv_isSign;
        @BindView(R.id.tv_classing)
        TextView tv_classing;

        public ViewHolder01(View itemView) {
            super(itemView);
        }
    }

    public class ViewHolder02 extends RecyclerView.ViewHolder {

        public ViewHolder02(View itemView) {
            super(itemView);
        }
    }
}
